package com.atguigu.spring.test;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @program: design-patterns
 * @author: yangshen
 * @description: 原型模式测试（浅拷贝）
 * @create: 2022-01-23 20:10
 **/
public class ProtoType {
    public static void main(String[] args) throws BeansException {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
        //获取monster[通过配置文件的id获取monster]
        Object bean1 = applicationContext.getBean("id01");
        System.out.println("bean1: " + bean1);

        Object bean2 = applicationContext.getBean("id01");
        System.out.println("bean2: " + bean2);

        //false : 按照原型模式创建的对象不是同一个对象
        System.out.println(bean1 == bean2);
    }
}
